package com.example.yjhmatch.controller;


import com.example.common.vo.Result;
import com.example.yjhmatch.mapper.MatchesMapper;
import com.example.yjhmatch.service.IMatchesService;
import com.yc.yjh.entity.Matches;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 赛程表 前端控制器
 * </p>
 *
 * @author 廖老师
 * @since 2023-07-20
 */
@RestController
@RequestMapping("/yjhmatch/matches")
public class MatchesController {
    @Resource
    MatchesMapper matchesMapper;

    @Resource
    IMatchesService matchesService;

    @RequestMapping("selectMatches")
    public List selectMatches(){
        return matchesService.list();
    }
    @RequestMapping("selectMatchesWithTeams")
    public Result selectMatchesWithTeams(){
        return Result.success("查询成功",matchesMapper.selectMatchesWithTeams());
    }

    @RequestMapping("selectMatchById")
    public Result selectMatchById(@RequestParam("mid") String mid){
        return Result.success("查询成功",matchesMapper.selectMatchById(mid));
    }
    @RequestMapping("selectMatchByName")
    public  Result selectMatchByName(@RequestParam("teamName") String teamName){
        return  Result.success("查询成功",matchesMapper.findByTeamName(teamName));
    }

    /**
     * 通过赛程ID，战队名，时间条件查询 赛事
     * @param mid
     * @param tname
     * @param time
     * @return
     */
    @RequestMapping("selectMatchByWrapper")
    public Result selectMatchByWrapper(@RequestParam("mid") String mid,@RequestParam("tname") String tname, @RequestParam("time") String time){
        final List<Matches> matches = matchesService.selectMatch(mid, tname, time);
        return Result.success("OK",matches);
    }

    @RequestMapping("selectMatchByDate")
    public Result selectMatchByDate(@RequestParam("date") String date){
        List<Matches> list=matchesMapper.selectMatchesByDate(date);
        return Result.success("查询成功",list);
    }
}

